package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 用户异常枚举
 * <p>
 * Created by chenwei on 2017/6/21.
 */
public enum AuthRoleExceptionEnum implements CustomExceptionCode {
   //异常枚举
    AUTHROLE_NOT_EXIST(600, "角色不存在", 900),
    AUTHROLE_NOT_ID(601, "角色ID为空", 900),
    AUTHROLE_EXIST_ALREADY(602, "角色已存在", 900),
    AUTHROLE_SAVE_ERROR(603, "保存角色信息失败", 900),
    PARAMETER_IS_NULL(604, "输入参数异常", 900),
    ROLE_IS_NULL(605, "查询的信息不存在", 900),
    AUTHROLE_UPDATE_ERROR(606, "更新角色信息失败", 900),
    AUTHROLE_DELETE_ERROR(607, "删除角色信息失败", 900),
    GETUSERASSIGNROLE_FAILER(608, "获取关联角色的用户信息失败", 900),
    ROLENAME_IS_NULL(609, "角色名称不能为空", 900),
    ROLEID_IS_NULL(610, "请选择用户", 900),
    ROLE_HAS_USER_OR_FUNCTION(611, "请先移除该角色下的账号和所有功能后再删除或禁用", 900),
    ADMIN_ANNNOT_DELETE(612, "超级管理员角色无法删除", 900),
    AUTHROLE_QUERY_ERROR(613, "获取角色信息失败", 900),
    FIND_ROLE_FUNCTION_ERROR(614, "获取角色关联的功能错误", 900),
    ROLE_SET_FUNCTION_ERROR(615, "角色分配功能错误", 900),
    ROLE_STATUS_ERROR(616, "角色禁用中，不能分配功能", 900),
    ROLE_USER_ERROR(617, "角色禁用中，不能分配账号", 900),



    ;

    private Integer code;
    private String msg;
    private Integer httpCode;

    AuthRoleExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }

    public static AuthRoleExceptionEnum getEnumByCode(Integer code){
        for(AuthRoleExceptionEnum roleExceptionEnum : AuthRoleExceptionEnum.values()){
            if(code.equals(roleExceptionEnum.getCode())){
                return roleExceptionEnum;
            }
        }
        return null;
    }
}
